﻿using System;
using RPC;

namespace Playground {
	[RPCID(1010)]//Very important, create id for message
	public class RPCLoginRequest : RPCMessage {
		#region Fields
		private String _username;
		private String _password;
		#endregion
		#region Public
		/// <summary>
		/// Writes the data.
		/// </summary>
		/// <param name="w">The writer.</param>
		public override void WriteData(RPCWriter w) {
			//Write your data
			w.Write(this.Username);//Write Username,
			w.Write(this.Password);//Write password
		}

		public override void ReadData(RPCReader r) {
			//Read your data
			this.Username = r.ReadString();
			this.Password = r.ReadString();
		}
		#endregion
		#region Property
		/// <summary>
		/// Gets or sets the username for login.
		/// </summary>
		/// <value>The username.</value>
		public String Username {
			get {
				return _username;
			}
			set {
				_username = value;
			}
		}
		/// <summary>
		/// Gets or sets the password.
		/// </summary>
		/// <value>The password.</value>
		public String Password {
			get {
				return _password;
			}
			set {
				_password = value;
			}
		}
		/// <summary>
		/// Gets a value indicating whether this <see cref="RPCLoginRequest"/> is valid.
		/// </summary>
		/// <value><c>true</c> if valid; otherwise, <c>false</c>.</value>
		public Boolean Valid {
			get {
				return !String.IsNullOrEmpty(this.Username) && !String.IsNullOrEmpty(this.Password);
			}
		}
		#endregion
	}
}
